<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateO2oOrderRefundRelationTable1554107659 extends Migration
{
	/**
	 * 换货申请-订单关系表
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		$prefix = config('ibrand.app.database.prefix', 'ibrand_');

		if (!Schema::hasTable($prefix . 'o2o_order_refund_relation')) {
			Schema::create($prefix . 'o2o_order_refund_relation', function (Blueprint $table) {
				$table->increments('id');
				$table->integer('order_id');    //新的订单ID
				$table->integer('refund_id');
				$table->integer('refund_amount');   //退款金额
				$table->integer('difference_amount');   //换货差价:<0 需要补款；>0需要退款
				$table->timestamps();
			});
		}
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		$prefix = config('ibrand.app.database.prefix', 'ibrand_');
		Schema::drop($prefix . 'o2o_order_refund_relation');
	}
}
